package com.tzstcl.sys.user.ctrl;

import com.github.pagehelper.PageInfo;
import com.tzstcl.base.ctrl.BaseCtrl;
import com.tzstcl.base.model.AjaxResult;
import com.tzstcl.sys.user.model.SysPosition;
import com.tzstcl.sys.user.service.SysPositionService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import java.util.List;

/**
 * 公司：天筑科技股份有限公司
 * 作者：zgq
 * 日期：2019年01月04日
 * 说明：职位信息表Controller
 */
@Controller
@RequestMapping("/admin/sysPosition")
public class SysPositionCtrl extends BaseCtrl {

    @Autowired
    private SysPositionService sysPositionService;

    /**
     * 新增 修改
     *
     * @param sysPosition
     * @return
     */
    @RequestMapping("/save")
    @RequiresPermissions(value = {"sysPosition:edite", "sysPosition:add"}, logical = Logical.OR)
    @ResponseBody
    public AjaxResult save(@Valid SysPosition sysPosition) {
        return toAjax(sysPositionService.insertOrUpdate(sysPosition));
    }

    /**
     * 删除
     *
     * @param ids
     * @return
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sysPosition:delete")
    @ResponseBody
    public AjaxResult delete(String ids) {
        return toAjax(sysPositionService.deleteBatchIds(ids));
    }

    /**
     * 获取单条信息
     *
     * @param id
     * @return
     */
    @RequestMapping("/get")
    @RequiresPermissions("sysPosition:view")
    @ResponseBody
    public AjaxResult get(Long id) {
        return success("获取信息成功", sysPositionService.getOne(id));
    }

    /**
     * 获取查询的分页数据
     *
     * @param sysPosition
     * @return
     */
    @RequestMapping("/list")
    @RequiresPermissions("sysPosition:view")
    @ResponseBody
    public PageInfo<SysPosition> list(SysPosition sysPosition) {
        return sysPositionService.selectPage(sysPosition);
    }

    /**
     * 获取信息
     *
     * @param sysPosition
     * @return
     */
    @RequestMapping("/info")
    @RequiresPermissions("sysPosition:view")
    @ResponseBody
    public List<SysPosition> info(SysPosition sysPosition) {
        return sysPositionService.selectList(sysPosition);
    }

    /**
     * list页面导航
     *
     * @return
     */
    @RequiresPermissions("sysPosition:view")
    @RequestMapping("/toList")
    public String toList() {
        return "admin/sys/user/sysPositionList";
    }


}